import { ApiProperty } from '@nestjs/swagger';
import { IsString, IsNotEmpty, IsEmail ,ValidateIf,IsOptional} from 'class-validator';

export class LoginDto {
    @ApiProperty({ required: true, description: '邮箱' })
    @IsEmail({}, { message: '邮箱格式错误' })
    @IsString({ message: '邮箱必须为字符类型' })
    @ValidateIf((o) => o.email != '')
    @IsNotEmpty({ message: '邮箱不能为空' })
    @IsOptional()
    readonly email: string;
    
    @ApiProperty({ required: true, description: '密码' })
    @IsString({ message: '密码必须为字符串类型' })
    @IsNotEmpty({ message: '密码不能为空' })
    readonly password: string;
}